# coding: utf-8
from hashlib import sha1, sha224, sha256, sha384, sha512, md5


class HashlibDemo:
    def _test_md5(self):
        """
        hd = HashlibDemo()
        hd._test_md5()
        """
        # md5加密
        encrypt_md5 = md5()
        encrypt_md5.update('haha'.encode())
        print(encrypt_md5.hexdigest(), ': ', len(encrypt_md5.hexdigest()))

    def _test_sha1(self):
        """
        hd = HashlibDemo()
        hd._test_sha1()
        """
        # sha1加密
        encrypt_sha1 = sha1()
        encrypt_sha1.update('haha'.encode())
        print(encrypt_sha1.hexdigest(), ': ', len(encrypt_sha1.hexdigest()))

    def _test_sha224(self):
        """
        hd = HashlibDemo()
        hd._test_sha224()
        """
        # sha224加密
        encrypt_sha224 = sha224()
        encrypt_sha224.update('haha'.encode())
        print(encrypt_sha224.hexdigest(), ': ', len(encrypt_sha224.hexdigest()))

    def _test_sha256(self):
        """
        hd = HashlibDemo()
        hd._test_sha256()
        """
        # sha256加密
        encrypt_sha256 = sha256()
        encrypt_sha256.update('haha'.encode())
        print(encrypt_sha256.hexdigest(), ': ', len(encrypt_sha256.hexdigest()))

    def _test_sha384(self):
        """
        hd = HashlibDemo()
        hd._test_sha384()
        """
        # sha384加密
        encrypt_sha384 = sha384()
        encrypt_sha384.update('haha'.encode())
        print(encrypt_sha384.hexdigest(), ': ', len(encrypt_sha384.hexdigest()))

    def _test_sha512(self):
        """
        hd = HashlibDemo()
        hd._test_sha512()
        """
        # sha512加密
        encrypt_sha512 = sha512()
        encrypt_sha512.update('haha'.encode())
        print(encrypt_sha512.hexdigest(), ': ', len(encrypt_sha512.hexdigest()))


if __name__ == '__main__':
    hd = HashlibDemo()
    hd._test_sha512()
